<div id="variations">
  <p>Variations: </p>
  <% if variations.frozen? %>
    <%= variations.collect { |v| v.name }.to_sentence -%>
  <% else %>
    <table class="detail-grid">
      <thead>
        <tr>
          <th>Name</th>
          <th>Price Effect</th>
          <th>
            Action               
            <%= image_tag "spinner.gif", :plugin=>"railscart", :style => "display:none", :id => 'delete_indicator' %>
          </th>
        </tr>
      </thead>
      <tbody>
        <% if variations.empty? %>
          <tr>
            <td colspan="3" align="center">None</td>
          </tr>
        <% end %>
        <% variations.each do |v| %>
          <tr>
            <td><%= v.name %></td>
            <td><%= v.price_effect %></td>
            <td>
              <%= link_to_remote "Delete",
                                 :url => {:controller => 'variations', :action => 'delete', :id=> v},
                                 :before => "Element.show('delete_indicator')",
                                 :confirm => "Are you sure you want to delete this variation?",  
                                 :update => 'variation' %>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>
    <br/>
    <div id="new-variation"></div>
    <div id="new-var-link">
      <% if product and not product.new_record?%>
        <%= link_to_remote "New Product Variation",
                           :url => {:controller => 'variations', :action => 'new'},
                           :before => "Element.show('busy_indicator')", 
                           :complete => "Element.hide('new-var-link');", 
                           :update => 'new-variation' %>
        <%= image_tag "spinner.gif", :plugin=>"railscart", :style => "display:none", :id => 'busy_indicator' %>
      <% end %>
      <% if category and not category.new_record? %>
        <%= link_to_remote "New Category Variation",
                           :url => {:controller => 'variations', :action => 'new'},
                           :before => "Element.show('busy_indicator')", 
                           :complete => "Element.hide('new-var-link');", 
                           :update => 'new-variation' %>
        <%= image_tag "spinner.gif", :plugin=>"railscart", :style => "display:none", :id => 'busy_indicator' %>
      <% end %>
    </div>
    <br/>
  <% end%>
</div>